<template>
  <el-radio-group
    v-model="currval"
    :disabled="component.disabled || this.disableds == true ? true : false"
    @change="$listeners.change($event)"
  >
    <el-radio
      v-for="item in options"
      :key="item.attrValue"
      :label="item.attrValue"
      >{{ item.attrValueName }}</el-radio
    >
  </el-radio-group>
</template>

<script>
import http from "../../utils/http";
export default {
  name: "DynRadio",
  props: {
    attrId: [String, Number],
    productId: [String, Number],
    value: [String, Number],
    component: {
      type: Object,
      default: () => {
        return {};
      },
    },
    disableds: {
      type: Boolean,
      default: () => {
        return false;
      },
    },
  },
  created() {
    this.getAttrValueList();
  },
  data() {
    return {
      options: [],
    };
  },
  computed: {
    currval: {
      get: function () {
        return this.value;
      },
      set: function (newValue) {
        this.$emit("input", newValue);
      },
    },
  },
  methods: {
    async getAttrValueList() {
      let res = await http({
        url: `${process.env.VUE_APP_CTX_ORDER_QUERY}/qryAttrValueList`,
        params: { attrId: this.attrId, productId: this.productId },
        method: "GET",
      });
      if (res.code == 200) {
        this.options = res.meta.attrValueList;
      } else {
        
      }
    },
  },
};
</script>
